
import realThing from "../BASE/realThing";
import Cspine from "../BASE/spineANDgif/Cspine";
import turn from "../game/time/turn";
import GeZiManager from "../Manager/GeZiManager";
import { Message } from "../Message/Message";
import MessageCenter from "../Message/MessageCenter";
import { SHMessage } from "../Message/SHMessage";

const {ccclass, property} = cc._decorator;

@ccclass
export default class Wcow extends realThing {

   HP: number=3;
   T:number=0;
nn:string="Wcow"
tt: string="animal";
   start(): void {
       super.start();
       turn.Roo.push(this);
       this.node.children[1].getComponent(cc.Label).string=this.T+","+this.nn+","+this.faceTo
       this.h()
   }
   roundPass(): void {
  if (this.HP>0) {
    
 
  
    let a= this.findGe(this.faceTo,1)
       GeZiManager.Tcharacter=null
   MessageCenter.MakeSHMessage("AM",[a],1,-1,"getOneC")

if((GeZiManager.BanMove.includes(a)&&GeZiManager.Tcharacter==null)||a==66){
   // MessageCenter.MakeSHMessage("AM",[ZB],1,this.Pturn,"HP-");
  //if (this.T==4) {
    //this.faceTo=this.turn4([this.faceTo])[0];
  //}else{     this.faceTo= this.turn6([this.faceTo])[0];}
 // this.node.getComponent(Cspine).changeDirection(this.faceTo)
 this.h()
}
   
MessageCenter.MakeSHMessage("AM",[a],1,-1,"wuli")
    MessageCenter.MakeSHMessage("AM",[a],[this.turn8([this.faceIs(a)])[0],0.5],-1,"move")
 
    MessageCenter.MakeSHMessage("AM",[this.ZB],[this.turn8([this.faceIs(a)])[0],0.6],-1,"move")
   
}
}
ReceiveMessage(message: Message): void {
   if (this.HP>0) {
    super.ReceiveMessage(message);
          this.h() }
      }


h(){

this.node.children[2].getComponent(cc.Label).string=this.HP.toString()
this.node.children[1].getComponent(cc.Label).string=this.T+","+this.nn+","+this.faceTo
//this.node.children[0].scaleY*=-1
let j=180;
switch (this.faceTo) {
    case 2:j=180;
        
        break;
        case 6:j=-90;
        
        break;
        case 4:j=90
        
        break;
    default:j=0
        break;
}
this.node.children[0].angle=j
}

dead(k:realThing): void {
  super.dead(k)
   
 //  this.deadgif();
   //GeZiManager.shanchu()


  if (k) {
  if ( this.getdis(k.ZB)<=1) {
    MessageCenter.MakeSHMessage("AM",[k.ZB],1,-1,"TNS+")
  }  
  }
  this.ZB=0
  this.node.active=false
  }






  
}